{include file="public/header" /}
<style>
    .layui-layer-prompt textarea.layui-layer-input {
        width: 300px;
        height: 36px;
        line-height: 20px;
        padding: 6px 10px;
    }

    .layui-layer-prompt .layui-layer-btn {
        height: 70px;
    }

    .layui-layer-prompt .layui-layer-btn .layui-layer-btn0 {
        height: 30px;
        font-size: 1rem !important;
    }

    .layui-layer-prompt .layui-layer-btn .layui-layer-btn1 {
        height: 30px;
        font-size: 1rem !important;
    }

    .layui-layer-prompt .layui-layer-btn a {
        line-height: 1.7rem;
    }

    .layui-layer-prompt .layui-layer-input {
        margin: 0 10px;
    }

    .custom-style {
        height: 6.6rem;
        width: 6.6rem;
        /*background: red;*/
        position: absolute;
        top: 22.5%;
        left: 16%;
        opacity: 0.5;
        transform: translateY(100%);
    }
</style>
<body class="hide-top">
<div class="earnings-container">
    <img src="/static/index/img/share_1.jpg" class="bg" alt="">
    <p class="flex-center code QRcode custom-style"></p>
    <!--    <div class="test"></div>-->
    <div class="earnings-content">
        <div class="earnings-hd flex-center">
            <i class="layui-icon layui-icon-left flex-center" onclick="history.go(-1)"></i>邀请中心
        </div>
    </div>
    <!--    <div class="share-content bgc">-->
    <!--        <div class="news">-->
    <!--            <p class="flex-center">-->
    <!--                <img src="{if $user.photo}{$user.photo}{else}cache('system')['default_photo']{/if}" alt="">-->
    <!--            </p>-->
    <!--            <p style="padding-top: 10px;font-size: 1.5rem;font-weight: bold">{$user.code}</p>-->
    <!--        </div>-->
    <!--        <p class="flex-center code QRcode"></p>-->
    <!--        <p>扫描二维码加入我的团队</p>-->
    <!--        <input type="hidden" id="copy" name="copy" value=""/>-->
    <!--        <p class="save copy" data-clipboard-target="#copy">复制链接</p>-->
    <!--    </div>-->
</div>
</body>
{include file="public/footer"/}
<script src="/static/index/js/qrcode.min.js"></script>
<script src="/static/index/js/clipboard.min.js"></script>
<script src="/static/index/js/utf.js"></script>
<script>

    layui.use(function () {
        const rem = document.querySelector('html').style.fontSize.replace('px','')
        var layer = layui.layer;
        layer.prompt({title: '请输入接点人', formType: 2}, function (text, index) {
            layer.close(index);
            $.ajax({
                type: 'POST',
                url: 'save_share.html',
                data: {'shar_place': text},
                dataType: "json",
                success: function (data) {
                    if (data.code == 1) {
                        $("#copy").val(data.url);
                        $(".QRcode").qrcode({
                            render: "canvas", //设置渲染方式，有table和canvas
                            text: data.url, //扫描二维码后自动跳向该链接
                            // width: "240", //二维码的宽度
                            width: (rem * 6.6).toString(), //二维码的宽度
                            // height: "240", //二维码的高度
                            height: (rem * 6.6).toString(), //二维码的高度
                            background: "#ffffff", //二维码的后景色
                            foreground: "#000000", //二维码的前景色
                            //src: 'images/logo.png', //二维码中间的图片
                        });
                    } else {
                        layer.msg(data.msg, {icon: 2, time: 2000}, function () {
                            parent.location.reload();
                        });
                    }
                }
            });
        });
    });

    $('.copy').click(function () {
        var clipboard = new ClipboardJS('.copy', {
            text: function () {
                return $("#copy").val();
            }
        });
        clipboard.on("success", function (e) {
            e.clearSelection();
            layer.msg('复制成功')
        });
        clipboard.on("error", function (e) {
            layer.msg('复制失败')
        });
    })
</script>
</html>